package AdminService

import (
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/util/gconv"
	"seawolf-admin-go/internal/request/BaseReq"
	"seawolf-admin-go/utility/response"
	"seawolf-admin-go/utility/token"
	"seawolf-admin-go/utility/tools"
)

func Logout(r *ghttp.Request, req *BaseReq.I) *response.JsonResponse {
	if req.AdminId < 1 {
		response.SuccessByRequestMessage(r, "登出成功")
	}
	ctx := r.GetCtx()
	stringAdminId := gconv.String(req.AdminId)
	// 清除缓存
	tools.ClaerCacheByKeyPrefix(ctx, "SelectCache:adminCache:"+stringAdminId+":*")
	token.LogoutByMemberId(ctx, stringAdminId)
	return response.SuccessByRequestMessage(r, "登出成功")
}
